﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net.Core;

namespace CYTS.Aoyou.Framework.Log
{
    internal class AOPLogImpl : LogImpl, IAOPLog
    {
        public AOPLogImpl(ILogger logger)
            : base(logger)
        {
        }



        public void Info(string id, string type, string method, string args, string returnType, long elapsedMilliseconds)
        {
            if (this.IsInfoEnabled)
            {
                LoggingEvent loggingEvent = new LoggingEvent(null, Logger.Repository, Logger.Name, Level.Info, string.Empty, null);
                loggingEvent.Properties["ID"] = id;
                loggingEvent.Properties["Type"] = type;
                loggingEvent.Properties["Method"] = method;
                loggingEvent.Properties["Args"] = args;
                loggingEvent.Properties["Return"] = returnType;
                loggingEvent.Properties["ElapsedMilliseconds"] = elapsedMilliseconds;
                Logger.Log(loggingEvent);
            }
        }

        public void Error(string id, string type, string method, string args, Exception ex)
        {
            if (this.IsErrorEnabled)
            {
                LoggingEvent loggingEvent = new LoggingEvent(null, Logger.Repository, Logger.Name, Level.Error, string.Empty, ex);
                loggingEvent.Properties["ID"] = id;
                loggingEvent.Properties["Type"] = type;
                loggingEvent.Properties["Method"] = method;
                loggingEvent.Properties["Args"] = args;
                Logger.Log(loggingEvent);
            }
        }
    }
}
